package com.ruoyi.project.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.GyProcess;
import com.ruoyi.project.service.IGyProcessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工艺设计工艺表Controller
 * 
 * @author xiangjun
 * @date 2021-12-14
 */
@RestController
@RequestMapping("/gongyi/gy_process")
public class GyProcessController extends BaseController
{
    @Autowired
    private IGyProcessService gyProcessService;

    /**
     * 查询工艺设计工艺表列表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_process:list')")
    @GetMapping("/list")
    public TableDataInfo list(GyProcess gyProcess)
    {
        startPage();
        List<GyProcess> list = gyProcessService.selectGyProcessList(gyProcess);
        return getDataTable(list);
    }

    /**
     * 导出工艺设计工艺表列表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_process:export')")
    @Log(title = "工艺设计工艺表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GyProcess gyProcess)
    {
        List<GyProcess> list = gyProcessService.selectGyProcessList(gyProcess);
        ExcelUtil<GyProcess> util = new ExcelUtil<GyProcess>(GyProcess.class);
        return util.exportExcel(list, "工艺设计工艺表数据");
    }

    /**
     * 获取工艺设计工艺表详细信息
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_process:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gyProcessService.selectGyProcessById(id));
    }

    /**
     * 新增工艺设计工艺表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_process:add')")
    @Log(title = "工艺设计工艺表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GyProcess gyProcess)
    {
        return toAjax(gyProcessService.insertGyProcess(gyProcess));
    }

    /**
     * 修改工艺设计工艺表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_process:edit')")
    @Log(title = "工艺设计工艺表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GyProcess gyProcess)
    {
        return toAjax(gyProcessService.updateGyProcess(gyProcess));
    }

    /**
     * 删除工艺设计工艺表
     */
    @PreAuthorize("@ss.hasPermi('gongyi:gy_process:remove')")
    @Log(title = "工艺设计工艺表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gyProcessService.deleteGyProcessByIds(ids));
    }
}
